package com.ryskoo.catering.vendortemplaterel.repository;

import com.ryskoo.catering.vendortemplaterel.domain.VendorTemplateRelPO;
import com.ryskoo.framework.core.repository.BasicJPAImpl;
import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class VendorTemplateRelJPAImpl extends BasicJPAImpl<VendorTemplateRelPO> implements IVendorTemplateRelRepository {
    @Override
    public void deleteByVendorUuid(String vendorUuid) {
        String hql = "delete from VendorTemplateRelPO o where o.vendorUuid = :vendorUuid";
        Query query = getH4Session().createQuery(hql);
        query.setString("vendorUuid",vendorUuid);
        query.executeUpdate();
    }

    @Override
    public List<String> getUuidsByVendorUuid(String vendorUuid) {
        String hql = "select o.uuid from VendorTemplateRelPO o where o.vendorUuid = :vendorUuid";
        Query query = getH4Session().createQuery(hql);
        query.setString("vendorUuid",vendorUuid);
        return query.list();
    }
}
